from jili.calc import calcor_base
from jili.calc.wavelet_llt import wavelet_llt
class LLT(calcor_base):
    def __init__(self,ta_arg={}):
        self.out = ["percent"]
        self.input = ["close"]
        self.parameters = {"timeperiod":10,"matype":9}
        super().__init__(ta_arg)
        self.batch=self.parameters["timeperiod"]
        self.llt=wavelet_llt(timeperiod=self.parameters["timeperiod"])
        self.isfirst=True
        self.lookback = self.batch - 1
    def calc(self):
        if self.isfirst:
            self.isfirst=False
            for i in self.hisbars[self.input[0]][:-1]:
                self.llt.ondata(i)
        data = self.hisbars[self.input[0]][-1]
        return self.llt.ondata(data,timekey=self.lasttimekey)
